
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>reflect对象</title>
</head>
<body>
    


    <script>
        // Reflect对象与Proxy对象一样，也是 ES6 为了操作对象而提供的新 API
        // 1:从`Reflect`对象上可以拿到语言内部的方法
        // 2:修改某些`Object`方法的返回结果，让其变得更合理
        // 3:让`Object`操作都变成函数行为
        // 4:`Reflect`对象的方法与`Proxy`对象的方法一一对应，只要是`Proxy`对象的方法，就能在`Reflect`对象上找到对应的方法。

        const ages = [11, 33, 12, 54, 18, 96];

        // 原生js实现
        let min=ages[0],max=ages[0];
        for (let i = 0; i < ages.length; i++) {
            if (min>ages[i]) {
                min = ages[i]
            }
            if (max<ages[i]) {
                max = ages[i]
            }
        }
        console.log(min);
        console.log(max);
        

        // const  youngest = Math.min.apply(Math,ages)
        // console.log(youngest);
        // const  oldest = Math.max.apply(Math,ages)
        // console.log(oldest);
        // console.log(Object.prototype.toString.call(youngest));
        // console.log(Object.prototype.toString.call(oldest));



        const  youngest = Reflect.apply(Math.min,Math,ages)
        console.log(youngest);
        const  oldest = Reflect.apply(Math.max,Math,ages)
        console.log(oldest);
        console.log(Object.prototype.toString.call(youngest));
        console.log(Object.prototype.toString.call(oldest));
        console.log(Reflect.apply(Object.prototype.toString, youngest, []));



        





    </script>
</body>
</html>